package entityUpdater

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commRedisRpc"
	"gitee.com/fierce_wolf/go-fox-edge-common/commSql"
	"gitee.com/fierce_wolf/go-fox-edge-common/edgeEntity"
)

type OperateRecordValueUpdater struct {
}

func (e *OperateRecordValueUpdater) updateOperateRecordValue(clientName string, operateRespondVO *commRedisRpc.OperateRespondVO) {
	if !operateRespondVO.Record {
		return
	}

	recordEntity := edgeEntity.Type.OperateRecordEntity.Instance()
	recordEntity.DeviceName = operateRespondVO.DeviceName
	recordEntity.DeviceType = operateRespondVO.DeviceType
	recordEntity.Manufacturer = operateRespondVO.Manufacturer
	recordEntity.RecordName = operateRespondVO.OperateName
	recordEntity.ClientModel = clientName
	recordEntity.OperateUuid = operateRespondVO.Uuid
	recordEntity.RecordParam = operateRespondVO.Param
	recordEntity.RecordData = operateRespondVO.Data

	// 保存到数据库
	commSql.InsertEntity(recordEntity)
}
